package com.treasure.mall.biz.repository.live;

import com.treasure.mall.biz.base.JpaSearchableRepository;
import com.treasure.mall.biz.entity.live.LiveRoomFanPO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 *
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.biz.repository.live
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/6/11 20:14
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * Copyright 2019-2022 com.treasure.mall.biz.repository.live Inc. All rights reserved.
 */
@Repository
public interface LiveRoomFanRepository extends JpaSearchableRepository<LiveRoomFanPO, Long> {
    void deleteByRoomIdAndUser_UserId(Long roomId, Long userId);

    LiveRoomFanPO findByRoomIdAndUser_UserId(Long roomId, Long userId);

    @Query("select count(p) from LiveRoomFanPO p where  p.room.id= ?1 and p.user.userId =?2")
    long countByRoomIdAndUserId(Long roomId, Long userId);


}
